﻿

using Knight.Models.Base;
using Knight.Models.Entity;
using Knlght.Data;
using Knlght.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Knight.Models.Services
{
    public class AdministratorsService :ServiceBase
    {

        public  ActionResponse Add(Administrators model) 
        {
            return doAction(() =>
            {
                var db = new RepositoryBase<DataContext>();
                return db.Insert(model,nameof(Administrators.Id),PrimaryKeyType.GUID);
            });
        }      
        public ItemResponse<Administrators> CheckLogin(string username, string password)
        {
            return GetModel(() =>
            {
                var db = new RepositoryBase<DataContext>();
                var query = new QueryRequest<Administrators>();
                query.Add(o => o.Username == username);
                password = Encipher(password);
                query.Add(o => o.Password == password);
                return db.GetEntity(query.SubQueries);
            });
        }

       

    }
}
